<!--#Include File="../conn.asp" -->
<!--#Include File="comm/inc.asp" -->
<%
'====================================================================
'= Team Elite - Elite Article System
'= Copyright (c) 2005 - 2006 Eason Chan All Rights Reserved.
'=-------------------------------------------------------------------
'= 版权协议：
'=	GPL (The GNU GENERAL PUBLIC LICENSE Version 2, June 1991)
'=-------------------------------------------------------------------
'= 文件名称：/Manager/Admin_Interface.asp
'= 摘    要：后台-接口文件
'=-------------------------------------------------------------------
'= 最后更新：eason007
'= 最后日期：2005-12-21
'====================================================================

Call EA_Manager.Chk_IsMaster

If Not EA_Manager.Chk_Power(Admin_Power,"71") Then 
	ErrMsg=str_Comm_NotAccess
	Call EA_Manager.Error(1)
End If

Dim Atcion
Atcion=Request.QueryString ("atcion")

Select Case LCase(Atcion)
Case "add"
	Call Add
Case "save"
	Call Save
Case "del"
	Call Del
Case Else
	Call Main
End Select
Call EA_Pub.Close_Obj
Set EA_Pub=Nothing

Sub Main
	Dim Count,PageCount,Page,OutStr,i
	Dim FieldName(1),FieldValue(1),TopicList
	Dim ListBlock,Temp
	
	Page=EA_Pub.SafeRequest(3,"page",0,1,0)
	
	PageContent=Template.LoadTemplate("admin_Interface_list.htm")

	Template.SetVariable "Language_Comm_ListEmpty",str_Comm_ListEmpty,PageContent
	Template.SetVariable "Language_Comm_Bar_Operation",str_Comm_Bar_Operation,PageContent
	Template.SetVariable "Language_Comm_Edit_Operation",str_Comm_Edit_Operation,PageContent
	Template.SetVariable "Language_Comm_Alert_Del_Operation",str_Comm_Alert_Del_Operation,PageContent
	Template.SetVariable "Language_Comm_Del_Operation",str_Comm_Del_Operation,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_Interface_Help",str_Interface_Help,PageContent

	Template.SetVariable "Language_Interface_List",str_Interface_List,PageContent
	Template.SetVariable "Language_Interface_Add",str_Interface_Add,PageContent
	Template.SetVariable "Language_Interface_Title",str_Interface_Title,PageContent
	Template.SetVariable "Language_Interface_RemoteURL",str_Interface_RemoteURL,PageContent
	Template.SetVariable "Language_Interface_StructFile",str_Interface_StructFile,PageContent
	Template.SetVariable "Language_Interface_Type",str_Interface_Type,PageContent


	ListBlock=Template.GetBlock("list",PageContent)

	Count=EA_M_DBO.Get_Interface_Total()(0,0)
	If Count>0 Then 
		Template.SetVariable "ListTempty","none",PageContent

		TopicList=EA_M_DBO.Get_Interface_List(Page,15)
	
	    For i=0 To Ubound(TopicList,2)
			Temp=ListBlock
  
			Template.SetVariable "InterfaceID",TopicList(0,i),Temp
			Template.SetVariable "InterfaceTitle",TopicList(1,i),Temp
			Template.SetVariable "InterfaceRemoteURL",TopicList(2,i),Temp
			Template.SetVariable "InterfaceStructFile",TopicList(3,i),Temp
			Select Case TopicList(4,i)
			Case 1
				Template.SetVariable "InterfaceType",str_Interface_Type_UserRegister,Temp
			Case 2
				Template.SetVariable "InterfaceType",str_Interface_Type_UserChanngePassword,Temp
			Case 3
				Template.SetVariable "InterfaceType",str_Interface_Type_UserChanngeInfo,Temp
			Case 4
				Template.SetVariable "InterfaceType",str_Interface_Type_UserPostArticle,Temp
			Case 5
				Template.SetVariable "InterfaceType",str_Interface_Type_ManagerPostArticle,Temp
			End Select
			
			Template.SetBlock "list",Temp,PageContent
		Next

		Template.SetVariable "PageListNav",EA_Manager.PageList(15,Count,Page,FieldName,FieldValue),PageContent
	End If
	Template.CloseBlock "list",PageContent
	

	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Add
	Dim PostId
	Dim Title,RemoteURL,StructFile,Types,SKey
	Dim Temp
	
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	
	Temp=EA_M_DBO.Get_Interface_Info(PostId)
	If IsArray(Temp) Then 
		Title		= Temp(0,0)
		RemoteURL	= Temp(1,0)
		StructFile	= Temp(2,0)
		Types		= Temp(3,0)
		SKey		= Temp(4,0)
	End If

	PageContent=Template.LoadTemplate("admin_interface_option.htm")

	Template.SetVariable "Language_Comm_Save_Button",str_Comm_Save_Button,PageContent
	Template.SetVariable "Language_Comm_Reset_Button",str_Comm_Reset_Button,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_Interface_Help",str_Interface_Help,PageContent

	Template.SetVariable "Language_Interface_List",str_Interface_List,PageContent
	Template.SetVariable "Language_Interface_Add",str_Interface_Add,PageContent
	Template.SetVariable "Language_Interface_Input",str_Interface_Input,PageContent
	Template.SetVariable "Language_Interface_Title",str_Interface_Title,PageContent
	Template.SetVariable "Language_Interface_RemoteURL",str_Interface_RemoteURL,PageContent
	Template.SetVariable "Language_Interface_StructFile",str_Interface_StructFile,PageContent
	Template.SetVariable "Language_Interface_Type",str_Interface_Type,PageContent
	Template.SetVariable "Language_Interface_Type_UserRegister",str_Interface_Type_UserRegister,PageContent
	Template.SetVariable "Language_Interface_Type_UserChanngePassword",str_Interface_Type_UserChanngePassword,PageContent
	Template.SetVariable "Language_Interface_Type_UserChanngeInfo",str_Interface_Type_UserChanngeInfo,PageContent
	Template.SetVariable "Language_Interface_Type_UserPostArticle",str_Interface_Type_UserPostArticle,PageContent
	Template.SetVariable "Language_Interface_Type_ManagerPostArticle",str_Interface_Type_ManagerPostArticle,PageContent
	Template.SetVariable "Language_Interface_SKey",str_Interface_SKey,PageContent

	Template.SetVariable "InterfaceID",PostId,PageContent
	Template.SetVariable "InterfaceTitle",Title,PageContent
	Template.SetVariable "InterfaceRemoteURL",RemoteURL,PageContent
	Template.SetVariable "InterfaceStructFile",StructFile,PageContent
	Template.SetVariable "InterfaceType_" & Types," selected",PageContent
	Template.SetVariable "InterfaceSKey",SKey,PageContent
	

	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Save
	Call EA_Pub.Chk_Post
	
	Dim Title,RemoteURL,StructFile,Types,SKey
	Dim PostId
	
	PostId		= EA_Pub.SafeRequest(3,"postid",0,0,0)
	Title		= EA_Pub.SafeRequest(2,"title",1,"",1)
	RemoteURL	= EA_Pub.SafeRequest(2,"remoteurl",1,"",0)
	StructFile	= EA_Pub.SafeRequest(2,"structfile",1,"",0)
	Types		= EA_Pub.SafeRequest(2,"type",0,0,0)
	SKey		= EA_Pub.SafeRequest(2,"skey",1,"",0)
	
	If Title="" Or Len(Title)>50 Then
		ErrMsg="对不起，接口说明长度不符！"
		ErrMsg=ErrMsg&"<li>长度等于0或大于50"
		Call EA_Manager.Error(1)
	End If
	If RemoteURL="" Or Len(RemoteURL)>150 Then
		ErrMsg="对不起，远程接口地址长度不符！"
		ErrMsg=ErrMsg&"<li>长度等于0或大于150"
		Call EA_Manager.Error(1)
	End If
	If StructFile="" Or Len(StructFile)>50 Then
		ErrMsg="对不起，接口文件路径长度不符！"
		ErrMsg=ErrMsg&"<li>长度等于0或大于50"
		Call EA_Manager.Error(1)
	End If
	If SKey="" Or Len(SKey)>50 Then
		ErrMsg="对不起，接口密匙长度不符！"
		ErrMsg=ErrMsg&"<li>长度等于0或大于50"
		Call EA_Manager.Error(1)
	End If
		
	If Rs.State=1 Then rs.Close
	If PostId<>0 Then
		Sql="Select * From [NB_Interface] Where [Id]="&PostId
		rs.Open Sql,Conn,2,2
	Else
		rs.Open "NB_Interface",Conn,2,2
		rs.AddNew
	End If
		rs("Title")=Title
		rs("RemoteURL")=RemoteURL
		rs("StructFile")=StructFile
		rs("Type")=Types
		rs("SKey")=SKey
		rs.update
	Rs.Close:Set Rs=Nothing
	
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect "admin_interface.asp"
End Sub

Sub Del
	Call EA_Pub.Chk_Post
	
	Dim PostId
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	
	SQL="delete from [NB_Interface] where ID="&PostId
	Conn.Execute(SQL)
	
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect Request.ServerVariables("HTTP_REFERER")
End Sub
%>